package io.renren.test;

/**
 * @Author 小坏
 * @Date 2021/1/30 15:49
 * @Version 1.0
 * @program: 父工程 gulimall 万物起源之地
 */


public class A {
    public static void main(String[] args) {
        //编译看左边、运行看右边、多态只能对子类重写父类的方法有用、属性不行


        B b = new C();

        if(b instanceof C){
            System.out.println("true");
        }else {
            System.out.println("false");
        }

        if(b instanceof D){
            System.out.println("true");
        }else {
            System.out.println("false");
        }


        b.getId();
        System.out.println( b.getName());

    }

}


class B {

    private String name ="Bsilly";


    public String getName() {
        return name;
    }

    public String getId() {
        System.out.println("B:");
        return "B";
    }
}


class C extends B {
    private String name ="Csilly";
    public String getId() {
        System.out.println("C:");
        return "C";
    }




}
class D extends B{
    private String name ="Dsilly";
    public String getId() {
        System.out.println("C:");
        return "C";
    }
    }
